<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>业务处理</title>
    <link rel="stylesheet" href="../../css/element.css">
    <link rel="stylesheet" href="../../css/base.css">
</head>
<body>
<div id="wrapper" v-cloak>
    <el-container>
        <el-aside :width="isCollapse ? '64px' : '200px'" style="background-color: black; transition:width .5s">
            <div style="background-color: black; height: 60px; line-height: 60px; text-align: center;
                color: white; font-size: 20px;">
                <transition name="el-fade-in-linear">
                    <span name="fade" v-show="!isCollapse"><a href="/page/end/mainui.html">管理页面</a></span>
                </transition>
            </div>
            <el-menu :default-openeds="['1']" style="border: none;" background-color="black" text-color="#fff" active-text-color="#ffd04b"
                     default-active="chargebus"
                     class="el-menu-vertical-demo" :collapse="isCollapse">
                <a href="/page/end/mainui.html">
                    <el-menu-item index="home">
                        <i class="el-icon-data-line"></i>
                        <span slot="title">首页</span>
                    </el-menu-item>
                </a>
                <el-submenu index="1" v-if="user.permission && user.permission.length > 0">
                    <template slot="title">
                        <i class="el-icon-menu"></i>
                        <span slot="title">信息管理</span>
                    </template>
                    <a :href=`${item.path}` v-for="item in user.permission" :key="item.id">
                        <el-menu-item :index="item.flag">
                            <i class="el-icon-s-data"></i>
                            <span slot="title">{{item.name}}</span>
                        </el-menu-item>
                    </a>
                </el-submenu>
            </el-menu>
        </el-aside>
        <el-container>
            <el-header style="background-color: black; line-height: 60px; color: white;">
                <el-row>
                    <el-col :span="1">
                        <i style="font-size: 22px; cursor: pointer"
                           :class="[isCollapse ? 'el-icon-s-unfold' : 'el-icon-s-fold']" @click="handleCollapse"></i>
                    </el-col>
                    <el-col :span="2" :offset="21" style="text-align: right">
                        <span style="color: white; margin-right: 10px">{{user.jobnum}}</span>
                        <el-dropdown>
                            <img src="/files/avatar"
                                 style="width: 40px; height: 40px; margin-right: 10px; border-radius: 50%">
                            <el-dropdown-menu slot="dropdown">
                                <a href="/page/end/person.html"
                                   style="display:inline-block; padding: 5px 0; width: 100px; text-align: center; color: black">个人信息</a>
                                <a @click="logout" href="#"
                                   style="display:block; width: 100px;  text-align: center; color: black">退出</a>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </el-col>
                </el-row>
            </el-header>
            <!-- 主体区域 -->
            <el-main>
                <div style="color: black; font-size: 20px; margin: 10px 0">业务管理</div>
                <div style="height: 1px; background-color: white"></div>
                <el-input v-model="search" style="width: 40%;" suffix-icon="el-icon-search" placeholder="请输入业务名称或者编号按回车搜索" @keyup.enter.native="loadTable"></el-input>
<!--                <el-button @click="createbusiness" type="primary" size="mini" style="margin: 10px 0">新建业务</el-button>-->
                <!--                <el-button @click="exp" type="primary" size="mini" style="margin: 10px 0">导出</el-button>-->
                <el-table
                        :data="tableData"
                        baorder
                        style="width: 100%">
                    <el-table-column
                            v-for="item in props1"
                            :prop="item.prop"
                            :label="item.label"

                    >
                    </el-table-column>
                    <el-table-column
                            fixed="right"
                            label="操作"
                            width="100">
                        <template slot-scope="scope">
                            <el-button @click="edit(scope.row)" type="text">详细信息</el-button>
                            <el-button @click="manage(scope.row)" type="text">处理</el-button>
                            <el-popconfirm
                                    @onConfirm="returnback(scope.row.id)"
                                    title="确定驳回？"
                            >
                                <el-button type="text" slot="reference">驳回</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-column>
                </el-table>
                <!-- 分页 -->
                <div style="background-color: white">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="pageNum"
                            :page-sizes="[5, 10, 20, 40]"
                            :page-size="pageSize"
                            layout="total, sizes, prev, pager, next, jumper"
                            :total="total">
                    </el-pagination>
                </div>
                <el-dialog title="新建业务" :visible.sync="dialogFormVisible" width="70%"
                           close-on-click-modal="false" close-on-press-escape="false" show-close="false">
                    <el-table
                            :data="hisdata"
                            border
                            style="width: 100%">
                        <el-table-column
                                v-for="item in props"
                                :prop="item.prop"
                                :label="item.label"

                        >
                        </el-table-column>

                    </el-table>

                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible = false">关 闭</el-button>
                        <!--                        <el-button type="primary" @click="save">新 建</el-button>-->
                    </div>

                </el-dialog>
            </el-main>
        </el-container>
    </el-container>
</div>

<script src="../../js/jquery.min.js"></script>
<script src="../../js/vue.min.js"></script>
<script src="../../js/element.js"></script>
<script src="../../js/tinymce/tinymce.min.js"></script>
<script src="../../js/base.js"></script>

<!--<script src="../../js/js/user.js"></script>-->


<script type="text/javascript">
    function user() {
        let urlBase = "/business/";
        new Vue({
            el: "#wrapper",
            data: {
                user: {},
                tableData: [],
                tableData1: [],
                pageNum: 1,
                pageNum1:1,
                pageSize: 5,
                pageSize1: 5,
                total: 0,
                total1:0,
                dialogFormVisible: false,
                entity: {},
                isCollapse: false,
                search: '',
                options: [],
                hisdata:[],
                props: [{"label":"时间","prop":"data"},{"label":"操作医生","prop":"doctor"},{"label":"操作内容","prop":"option"}],
                props1: [{"label":"业务序号","prop":"id"},{"label":"源项目编号","prop":"bussinessid"},{"label":"当前所在的流程","prop":"currentprocess1"},{"label":"处理医生","prop":"currentposition"}]

            },
            created() {
                this.user = sessionStorage.getItem("user") ? JSON.parse(sessionStorage.getItem("user")) : {};
                this.loadTable();
            },
            mounted(){
                this.initpage();
            },
            methods: {
                manage(obj){
                    $.get(urlBase + "/gethisturl?id=" + obj.id).then(res => {

                        console.log(res);
                        // let url =
                        // alert(res.frontpath+"?currentbussnessnum="+obj.bussinessid);
                        location.href = res.data.frontpath+"?currentbussnessnum="+obj.id;
                    })
                },
                initpage(){
                    $.ajax({
                        url: "/user/getuser",
                        type: type,
                        contentType: "application/json",
                        data: JSON.stringify(this.user)
                    }).then(res =>{
                        console.log(this.user);
                    })
                },
                createt(data){
                    console.log(urlBase + "initprocess&bussinessnum="+data.id);
                    $.get(urlBase + "initprocess?&bussinessnum="+data.id).then(res => {
                        // alert(res.data.frontpath);
                        console.log(res);
                        location.href = "../../" + res.data.frontpath+"?currentbussnessnum=" + res.data.currentbussnessnum;
                    })
                },
                handleCollapse() {
                    this.isCollapse = !this.isCollapse;
                },
                logout() {
                    // 请求退出接口
                    $.get("/user/logout");
                    localStorage.removeItem("user");
                    location.href = "mainui.hmtl";
                },
                loadTable() {
                    // urlBase + "/getallbusinessmsg?pageNum=" + this.pageNum + "&pageSize=" + this.pageSize
                    $.get(urlBase + "/getallbusinessmsg?pageNum=" + this.pageNum + "&pageSize=" + this.pageSize).then(res => {
                        console.log(this.pageNum);
                        console.log(this.pageSize);
                        console.log(res);
                        this.tableData = res.data.records;
                        this.total = res.data.total;
                    })

                    $.get("/role").then(res => {
                        this.options = res.data;
                    })
                },
                exp() {
                    window.open(urlBase + "/export");
                },
                handleSizeChange(pageSize) {
                    this.pageSize = pageSize;
                    this.loadTable();
                },
                handleCurrentChange(pageNum) {
                    this.pageNum = pageNum;
                    this.loadTable();
                },
                // handleSizeChange1(pageSize) {
                //     this.pageSize1 = pageSize;
                //     this.createbusiness();
                // },
                // handleCurrentChange1(pageNum) {
                //     this.pageNum1 = pageNum;
                //     this.createbusiness();
                // },
                //找到该用户所能创建的业务,传入的是user.jobnum
                createbusiness() {
                    $.get(urlBase + "/businesscreatemsg?pageNum=" + this.pageNum1 + "&pageSize=" + this.pageSize1 + "&doctorid=" + this.user.jobnum).then(res => {
                        this.tableData1 = res.data.records;
                        this.total1 = res.data.total;
                        console.log(this.tableData1);
                    })

                    this.dialogFormVisible = true;
                },

                edit(obj) {
                    console.log(obj)
                    this.dialogFormVisible = true;
                    //businessid
                    $.get(urlBase + "gethis?businessid="+ obj.id).then(res => {
                        this.hisdata = res.data;

                    })
                },
                returnback(id) {
                    $.ajax({
                        url: urlBase+"reject",
                        type: "POST",
                        contentType: "application/json",
                        data: JSON.stringify({
                            currentbussnessnum:id,
                            rejectmsg:"reject"
                        })
                    }).then(res => {
                        if (res.code === '0') {
                            this.$message({
                                message: "成功",
                                type: "success"
                            })
                            this.loadTable();
                        } else {
                            this.$message({
                                message: res.msg,
                                type: "error"
                            })
                        }
                    })
                }
            }
        })

    }


    user();
</script>


</body>
</html>
